/*
 * Timer.h
 *
 * Created: 1/18/2013 6:01:20 PM
 *  Author: Hp-Minion
 */ 


#ifndef TIMER_H_
#define TIMER_H_
/*****************************************************************************************/
/*
	INCLUDES
*/		
		#include "General.h"

/*****************************************************************************************/
/*
	DEFINES
*/	
		// CPU clock. Otherwise it will just jump to the default 1Mhz clock
		#ifdef F_CPU
		#  undef F_CPU
		#  define F_CPU 16000000UL
		# warning "F_CPU is re-defined as 16MHz"
		#else
		#  define F_CPU 16000000UL
		# warning "F_CPU is defined as 16MHz"
		#endif
		
		#define NumberOfCounts61 61	//counts for 1 sec
		#define DAY_OVERFLOWS 5273438UL
		#define Freq_4us 4
		#define Freq_16us 16
		#define Freq_64us 64
		#define PWM_MAX_BUFFER 1023	
/*****************************************************************************************/
/*
	VARIABLES
*/
		volatile unsigned long counter0;
		volatile unsigned long counter00;
		volatile unsigned long counter000;
		volatile unsigned long counter1;
		volatile unsigned long counter2;
		volatile unsigned long counter20;
		volatile unsigned long counter200;
		volatile unsigned int pwm;
/*****************************************************************************************/
/*
	FUNCTION PROTOTYPES
*/	
		extern void Delay_us(unsigned int );
		extern void Delay_ms(unsigned int );
 		void Init_timer0_us(void);
		void Init_timer0_ms(void);
		void Init_timer0_s(void);
		extern void Start_Timer0(void);
		extern unsigned long Stop_Timer0(void);
		extern void Init_timer2(void);
		extern void Init_PWM1(void);
		extern void SetDutyCycle(unsigned int );

/*****************************************************************************************/
#endif /* TIMER_H_ */